package 字符串;

import java.util.Scanner;

public class StringTest2 {
    public static void main(String[] args) {
        /**
         * 需求 : 键盘录入一个字符串，统计该字符串中大写字母字符，小写字母字符，数字字符出现的次数
         * (不考虑其他字符)
         */
        Scanner sc = new Scanner(System.in);
        System.out.println("键盘录入一个字符串：");
        String str = sc.next();

        int a = 0, b = 0, c = 0;
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            char ch = chars[i];
            if (ch>='a'&&ch<='z'){
                a++;
            } else if (ch>='A'&&ch<='Z') {
                b++;
            } else if (ch>='0'&&ch<='9'){
                c++;
            }
        }
        System.out.println("小写字母有："+a+"个");
        System.out.println("大写字母有："+b+"个");
        System.out.println("数字有："+c+"个");

    }
}
